package com.geekteam.manga.Model;

import com.geekteam.manga.provider.MangaContract.ContentManga;

import android.content.ContentValues;
import android.database.Cursor;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.BaseColumns;

public class ContentMangaModel extends BaseModel{
	
	private String mangaId;
	private String chapId;
	private String content;
	
	public ContentMangaModel(int _id, String mangaId, String chapId, String content){
		super(_id);
		this.mangaId = mangaId;
		this.chapId = chapId;
		this.content = content;
	}
	

	public ContentMangaModel(Cursor cursor) {
		super(cursor);
		this._id = cursor.getInt(cursor.getColumnIndex(BaseColumns._ID));
		mangaId = cursor.getString(cursor.getColumnIndex(ContentManga.MANGA_ID));
		chapId = cursor.getString(cursor.getColumnIndex(ContentManga.MANGA_CHAPID));
		content = cursor.getString(cursor.getColumnIndex(ContentManga.MANGA_CONTENT));
	}
	
	public ContentValues contentValues(long id){
		ContentValues values = new ContentValues();
		
		values.put(ContentManga.MANGA_ID, mangaId);
		values.put(ContentManga.MANGA_CHAPID, chapId);
		values.put(ContentManga.MANGA_CONTENT, content);
		return values;
	}
	
	 static public String[] contentColumns (){
		return new String[] {ContentManga.MANGA_ID, ContentManga.MANGA_CHAPID, 
				ContentManga.MANGA_CONTENT, ContentManga._ID};
	 }

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		dest.writeInt(_id);
		dest.writeString(mangaId);
		dest.writeString(chapId);
		dest.writeString(content);
		
	}
	
	public void readFromParcel(Parcel from){
		_id = from.readInt();
		mangaId  =from.readString();
		chapId = from.readString();
		content = from.readString();
	}
	
	public ContentMangaModel (Parcel parcel){
		super(parcel);
		readFromParcel(parcel);
		
	}
	
	@SuppressWarnings("rawtypes")
	public static final Parcelable.Creator CREATOR = new Parcelable.Creator<ContentMangaModel>() {

		@Override
		public ContentMangaModel createFromParcel(Parcel source) {
			return new ContentMangaModel(source);
		}

		@Override
		public ContentMangaModel[] newArray(int size) {
			return new ContentMangaModel[size];
		}
	};
	
	public void setMangaId(String mangaId){
		this.mangaId = mangaId;
	}
	
	public String getMangaId(){
		return mangaId;
	}
	
	public void setChapId(String chapId){
		this.chapId = chapId;
	}
	
	public String getChapId(){
		return chapId;
	}
	
	public String getContent(){
		return content;
	}
	
	public void setContent(String content){
		this.content = content;
	}

}
